<?php
declare(strict_types=1);

namespace App\Common\Modular\System\Traits\Configure\Traits;

use Core\Package\ElementPlus\Component\Component;
use Core\Package\ElementPlus\FormCreate\FormItem;

trait AiForm
{
    public function getAiFormRule($configure): array
    {
        return [
            FormItem::Radio('open', '启用', $configure['open'] ?? '0')->options([
                ['value' => '0', 'label' => '关闭AI'],
                ['value' => '1', 'label' => '开启AI']
            ])->control([
                [
                    'value' => '0',
                    'rule' => [
                        Component::Alert('AI功能已关闭', 'error')->style(['margin' => '0 0 20px 150px'])
                    ]
                ],
                [
                    'value' => '1',
                    'rule' => [
                        FormItem::Radio('model', '接入模型', $configure['model'] ?? '')->options([
                            ['value' => 'deepseek', 'label' => 'DeepSeek']
                        ])->control([
                            [
                                'value' => 'deepseek',
                                'rule' => [
                                    Component::Alert('已选择DeepSeek', 'success')->style(['margin' => '0 0 20px 150px']),
                                    FormItem::Input('key', 'KEY', $configure['key'] ?? '')->required()->hint('KEY申请地址:https://platform.deepseek.com/api_keys'),
                                ]
                            ]
                        ])
                    ]
                ]
            ])
        ];
    }
}